﻿using FormulaOne.Api.Services.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FormulaOne.Api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class DriversController : ControllerBase
    {
        private readonly IDriverNotificationPublishService _driverNotificationPublishService;
        public DriversController(IDriverNotificationPublishService driverNotificationPublishService)
        {
            _driverNotificationPublishService = driverNotificationPublishService;
        }

        [HttpPost]
        public async Task<IActionResult> AddDriver([FromBody] CreateDirverRequest diver)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            var id = Guid.NewGuid();
            await _driverNotificationPublishService.SendNotification(Guid.NewGuid(), "Mercedes");

            return CreatedAtAction(nameof(GetDirver), new { driverId = id });
        }


        [HttpGet]
        public async Task<IActionResult> GetDirver(Guid id)
        {
            return Ok(id);
        }
    }

    public class CreateDirverRequest
    {
        public string Name { get; set; }
    }
}
